#include<iostream>
#include<unistd.h>

using namespace std;

//模拟僵尸进程
int main()
{
    pid_t pid=fork();
    if(pid==0)     //子进程
    {
        sleep(2);
        cout<<"This is Child Process,PID is : "<<getpid()<<","<<"PPID is: "<<getppid()<<endl;
        sleep(2);
        return 0;
    }
    else if(pid<0)          //子进程创建失败
    {
        exit(1);
    }
    if(pid>0)          //父进程
    {
        sleep(2);
        cout<<"This is Father Process,PID is : "<<getpid()<<","<<"PPID is: "<<getppid()<<endl;
        sleep(20);
        return 0;
    }
    return 0;
}